home *** CD-ROM | disk | FTP | other *** search
- ---SEGMENTS.DOC---
-
- Segments in A86
-
- A86 views the 86 computer's memory space as having two parts: The first part is
- the program, whose contents are the object bytes generated by A86 during its
- assembly of the source. A86 calls this area the CODE SEGMENT. The second part
- is the data area, whose contents are generated by the program after it starts
- running. A86 calls this area the DATA SEGMENT.
-
- Please note well that the only difference between the CODE and DATA segments is
- whether the contents are generated by the program or the assembler. The names
- CODE and DATA suggest that program code is placed in the CODE segment, and data
- structures go in the DATA segment. This is mostly true, but there are
- exceptions. For example, there are many data structures whose contents are
- determined by the assembler: pointer tables, arrays of pre-defined constants,
- etc. These tables are assembled in the CODE segment.
-
- In general, you will want to begin your program with the directive DATA SEGMENT,
- followed by an ORG statement giving the address of the start of your data area.
- You then list all your program variables and uninitialized data structres, using
- the directives DB, DW, and STRUC. A86 will allocate space starting at the
- address given in the ORG statement, but it will not generate any object bytes in
- that space. After your data segment declarations, you provide a CODE SEGMENT
- directive, following by an ORG giving the address of the start of your program.
- You follow this with the program itself, together with any assembler-generated
- data structures. A short program illustrating this suggested usage follows:
-
- DATA SEGMENT
- ORG 08000
- ANSWER_BYTE DB ?
- CALL_COUNT DW ?
-
- CODE SEGMENT
- JMP MAIN
-
- TRAN_TABLE:
- DB 16,3,56,23,0,9,12,7
-
- MAIN:
- MOV BX,TRAN_TABLE
- XLATB
- MOV ANSWER_BYTE,AL
- INC CALL_COUNT
- RET
-
- A86 allows you to intersperse CODE SEGMENTs and DATA SEGMENTs throughout yuor
- program; but in general it is best to put all your DATA SEGMENT declarations at
- the top of your program, to avoid problems with forward-referencing.
-
-
- CODE ENDS and DATA ENDS Statements
-
- For compatibility with Intel/IBM assemblers, A86 provides the CODE ENDS and
- DATA ENDS statements. The CODE ENDS statement is ignored; we assume that you
- have not nested a CODE segment inside a DATA segment. The DATA ENDS statement
- is equivalent to a CODE SEGMENT statement.
-